﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AdminController;

namespace HPMDesktop.Admin.NurseAdmin
{
    public partial class frmNurseAddEdit : Form
    {
        public frmNurseAddEdit()
        {
            InitializeComponent();
        }

        private void cmdSave_Click(object sender, EventArgs e)
        {
            bool result;
            Nurse objData = new Nurse();
            Nurse_Mapper objMapper = new Nurse_Mapper();

            objData.NurseID = "1"; //test

            try
            {
                objData.FullName = Convert.ToString(FullName.Text);
                objData.Address = Convert.ToString(Address.Text);
                objData.City = Convert.ToString(City.Text);
                objData.State = Convert.ToString(State.Text);
                objData.ZipCode = Convert.ToString(ZipCode.Text);
                objData.MobilePhone = Convert.ToString(MobilePhone.Text);
                objData.OfficePhone = Convert.ToString(OfficePhone.Text);
                objData.HomePhone = Convert.ToString(HomePhone.Text);
                objData.EmailAddress = Convert.ToString(EmailAddress.Text);
                objData.EmergencyContactName = Convert.ToString(EmergencyContactName.Text);
                objData.EmergencyContactPhone = Convert.ToString(EmergencyContactPhone.Text);
                objData.Category = Convert.ToString(Category.Text);

                result = objMapper.Load_Nurse_DATA(objData.NurseID, objData);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                objData.Dispose();
                objMapper.Dispose();

            }

        }

        private void frmNurseAddEdit_Load(object sender, EventArgs e)
        {
            string ID;

            //ID = Request.Form("ID");
            ID = "1";

            Nurse objData = new Nurse();
            Nurse_DataLoader objDataLoader = new Nurse_DataLoader();

            try
            {

                objData = objDataLoader.Get_Nurse_DATA(ID);

                FullName.Text = Convert.ToString(objData.FullName);
                Address.Text = Convert.ToString(objData.Address);
                City.Text = Convert.ToString(objData.City);
                State.Text = Convert.ToString(objData.State);
                ZipCode.Text = Convert.ToString(objData.ZipCode);
                MobilePhone.Text = Convert.ToString(objData.MobilePhone);
                OfficePhone.Text = Convert.ToString(objData.OfficePhone);
                HomePhone.Text = Convert.ToString(objData.HomePhone);
                EmailAddress.Text = Convert.ToString(objData.EmailAddress);
                EmergencyContactName.Text = Convert.ToString(objData.EmergencyContactName);
                EmergencyContactPhone.Text = Convert.ToString(objData.EmergencyContactPhone);
                Category.Text = Convert.ToString(objData.Category);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                objData.Dispose();
                objDataLoader.Dispose();

            }

        }

        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
